import { Ajax } from "@/api/api";
import { fromJS, List } from "immutable";
import { action, makeObservable, observable } from "mobx"

class MyData {
    constructor() {
        makeObservable(this)
    }

    @observable count = 2000;

    @observable userInfo: any = fromJS({

    })

    @observable roleList: any = List([])

    @action changeCount = (payload: number) => {
        this.count += payload
        console.log(this.count)
    }

    @action changeUserInfo = (payload: any) => {
        this.userInfo = fromJS(payload)
    }

    @action getRoleListAsync = async (payload?: any) => {
        let res: any = await Ajax.getrolelist(payload)
        if (res.code == 200) {
            this.roleList = List(res.result)
        }
    }
}

export default new MyData